﻿using System;
using System.Configuration;
using System.IO;
using Topshelf;

namespace LMS.DocumentConvert
{
    internal class Program
    {
        public static readonly int MaxThreads = Convert.ToInt32(ConfigurationManager.AppSettings["ListenerThreads"]);
        public static readonly int ListenerPort = Convert.ToInt32(ConfigurationManager.AppSettings["ListenerPort"]);
        public static readonly int TimeoutSeconds = Convert.ToInt32(ConfigurationManager.AppSettings["TimeoutSeconds"]);
        public static readonly string PhantomjsNetstatFilter = ConfigurationManager.AppSettings["PhantomjsNetstatFilter"];

        public static void Main(string[] args)
        {
            HostFactory.Run(x =>
            {
                x.Service<ServiceHandle>(s =>
                {
                    s.ConstructUsing(name => new ServiceHandle());
                    s.WhenStarted(tc => tc.Start());
                    s.WhenStopped(tc => tc.Stop());
                });
                x.RunAsLocalService();

                x.SetDescription("将Office文件转换为Pdf格式");
                x.SetDisplayName("LMS.DocumentConvert2Pdf");
                x.SetServiceName("LMS.DocumentConvert2Pdf");
            });
        }
    }
}